﻿/* 
 * GeneralDesign.cs
 * 
 * Author - Ankit Gupta and Gaurav Aggarwal
 * 
 * This file handles component design of General tab.
 * 
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Text;
using System.ServiceProcess;

partial class GeneralControl
{
    public IContainer components = new Container();
    public Timer serviceTimer;
    public ServiceController clientServiceController = new ServiceController();
    public Label afsClientStateLabel = new Label();
    public Button startServiceButton = new Button();
    public Button stopServiceButton = new Button();
    public Button applyButton = new Button();
    public Button cancelButton = new Button();
    public TextBox stateTextBox = new TextBox();
    public GroupBox grpbox = new GroupBox();

    public GeneralControl()
    {
        clientServiceController.ServiceName = "TransarcAFSDaemon";

        // Timer properties
        serviceTimer = new Timer(components);
        serviceTimer.Interval = 1000;
        serviceTimer.Tick += new System.EventHandler(serviceTimer_Tick);

        grpbox.Location = new System.Drawing.Point(20, 10);
        grpbox.Name = "grpBox";
        grpbox.Size = new System.Drawing.Size(380, 100);
        grpbox.Text = "AFS Client Service";

        afsClientStateLabel.Location = new System.Drawing.Point(25, 35);
        afsClientStateLabel.Name = "afsClientStateLabel";
        afsClientStateLabel.Text = "State";

        // State (running or stopped) of OpenAfs Client
        stateTextBox.Location = new System.Drawing.Point(130, 35);
        stateTextBox.Name = "stateTextBox";
        stateTextBox.ReadOnly = true;
        stateTextBox.Size = new System.Drawing.Size(250, 30);

        // Start button - turns state to running
        startServiceButton.Location = new System.Drawing.Point(130, 70);
        startServiceButton.Name = "startServiceButton";
        startServiceButton.Size = new System.Drawing.Size(100, 23);
        startServiceButton.Text = "Start Service";
        startServiceButton.Click += new System.EventHandler(startServiceButton_Click);

        // Stop button - turns state to stopped
        stopServiceButton.Location = new System.Drawing.Point(280, 70);
        stopServiceButton.Name = "stopServiceButton";
        stopServiceButton.Size = new System.Drawing.Size(100, 23);
        stopServiceButton.Text = "Stop Service";
        stopServiceButton.Click += new System.EventHandler(stopServiceButton_Click);

        Refresh();

        // Apply button
        applyButton.Location = new System.Drawing.Point(20, 460);
        applyButton.Name = "applyButton";
        applyButton.Size = new System.Drawing.Size(100, 23);
        applyButton.Text = "Apply";
        applyButton.Click += new System.EventHandler(applyButton_Click);

        // Cancel button
        cancelButton.Location = new System.Drawing.Point(140, 460);
        cancelButton.Name = "cancelButton";
        cancelButton.Size = new System.Drawing.Size(100, 23);
        cancelButton.Text = "Cancel";
        cancelButton.Click += new System.EventHandler(cancelButton_Click);
    }
}